﻿using UnityEngine;
using System.Collections;

public class BiasSlider : MonoBehaviour
{
    public float begin = 0;
    public float end = 1;
    public UITexture texture;
    public Renderer render;

    void Awake()
    {
        Material mat = Instantiate(texture.material) as Material;
        texture.material = mat;
    }

    public void SetValue(float value)
    {
        texture.material.SetTextureOffset("_AlphaTex",new Vector2(Mathf.Lerp(begin,end,value),0));
        render.material.SetTextureOffset("_AlphaTex", new Vector2(Mathf.Lerp(begin, end, value), 0));
    }

    public float value;
    private float ov;
    public void Update()
    {
        if(value != ov)
        {
            SetValue(value);
            ov = value;
        }
    }
}
